package com.lanyou.esb.redis.proxy;

import java.io.IOException;

import redis.clients.jedis.Jedis;

import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;

/**
 * Redis代理接口
 * 
 * @author Davey.wu
 */
public interface JedisProxy<T> {

	/**
	 * 根据目标对象生成REDIS键
	 * 
	 * @param target
	 *            :目标对象
	 * @return
	 */
	String generateKeyFromObject(T target);

	/**
	 * 生成REDIS键
	 * 
	 * @param field
	 *            ：域名
	 * @return
	 */
	String generateKey(String field);

	/**
	 * 生成REDIS键
	 * 
	 * @param fields
	 *            ：域名列表
	 * @return
	 */
	String generateKey(String... fields);

	/**
	 * 擦除
	 * 
	 * @throws IOException
	 * @throws JsonMappingException
	 * @throws JsonParseException
	 */
	T erase(Jedis jedis) throws JsonParseException, JsonMappingException,
			IOException;

	/**
	 * 取消擦除
	 * 
	 * @param jedis
	 * @param target
	 * @return
	 * @throws JsonParseException
	 * @throws JsonMappingException
	 * @throws IOException
	 */
	void unErase(Jedis jedis, T target) throws JsonParseException,
			JsonMappingException, IOException;
}
